package org.example.pattern.strategy;

import java.util.concurrent.TimeUnit;

public class StrategyA implements Strategy {

    private String s1;
    private int num;
    private String name;

    public StrategyA() {

    }

    public StrategyA(String name, String s1, int num) {
        this.name = name;
        this.s1 = s1;
        this.num = num;
    }


    @Override
    public Result<String> validate() {
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        if (s1.equals("a") && num == 1) {
            return Result.result(200, this.getName() + " success","dataxxxxxx");
        }
        return Result.result(-1, this.getName() + " error","dataxxxxxx");
    }

    @Override
    public String getName() {
        return this.name;
    }
}
